<?php
if($this->do==''||$this->do=='config'){
	$this->check_access('global_admin');
	$this->template->out('global.config.php');
}
if($this->do=='config_update'){
	$this->check_access('global_config');
	$array=array();
	$array['title']=empty($_POST['title'])?'':trim($_POST['title']);
	$array['author']=empty($_POST['author'])?'':addslashes(trim($_POST['author']));
	$array['keywords']=empty($_POST['keywords'])?'':addslashes(trim($_POST['keywords']));
	$array['description']=empty($_POST['description'])?'':addslashes(trim($_POST['description']));
	$array['statcode']=empty($_POST['statcode'])?'':trim($_POST['statcode']);

	$array['smtp_server']=empty($_POST['smtp_server'])?'':addslashes(trim($_POST['smtp_server']));
	$array['smtp_user']=empty($_POST['smtp_user'])?'':addslashes(trim($_POST['smtp_user']));
	$array['smtp_password']=empty($_POST['smtp_server'])?'':addslashes(trim($_POST['smtp_password']));
	$array['smtp_port']=empty($_POST['smtp_server'])?'':addslashes(trim($_POST['smtp_port']));
	$array['smtp_mail']=empty($_POST['smtp_mail'])?'':addslashes(trim($_POST['smtp_mail']));
	$theme_config_include=ROOT.'/core/themes/'.$this->theme.'/config.php';
	if(file_exists($theme_config_include)){
		@include $theme_config_include;
	}
	$config_value=base64_encode(serialize($array));
	$this->db->update(DB_PREFIX."config",array('config_value'=>$config_value),"config_type='config'");
	clear_cache();
	if(get_ip()!='127.0.0.1'){
		echo "<iframe src='http://yckit.com/api/?domain=".$_SERVER['SERVER_NAME']."&version=v2012_beta1' style='display:none'></iframe>";
	}
	redirect('?action=global&do=config');
}
if($this->do=='theme_config'){
	$this->template->template_dir=ROOT.'/core/themes/'.$this->theme;
	$this->template->out('config.template.php');
}